<script setup>
// 导入根路径
// import { baseURL } from '../config'
// import { getGoodsListService } from '@/api/goods'
import router from '@/router';
import { defineProps } from 'vue'

// 获取自定义属性
defineProps({
  goods: {
    required: true
  }
})

const gotoDetail = (goodsId) => {
  router.push('/detail?goodsId=' + goodsId)
}

</script>

<template>
  <div v-for="item in goods" :key="item.goodsId">
    <div class="item" @click="gotoDetail(item.goodsId)">
      <!-- <img src="@/assets/沪上阿姨.png" /> -->
      <img :src="item.goodsImg" />
      <div class="name">{{ item.goodsName }}</div>
      <div class="title">标题</div>
      <div>
        <span class="selling_price">￥{{ item.price }}元</span>
        <span class="price">￥售价元{{ item.price }}</span>
      </div>
    </div>
  </div>
</template>

<style  lang='less' scoped>
.item {
  cursor: pointer;
  width: 234px;
  height: 260px;
  background: #fff;
  padding: 20px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s linear;
  float: left;
  margin: 0 0 14px 14px;
  position: relative;
  &:hover {
    transform: translate3d(0, -2px, 0);
    box-shadow: 0 15px 30px rgb(0 0 0 / 10%);
  }
  img {
    width: 160px;
    height: 160px;
  }
  .name {
    font-size: 14px;
    color: #333;
  }
  .title {
    font-size: 12px;
    color: #b0b0b0;
    margin: 10px 0;
  }
  .selling_price {
    font-size: 14px;
    color: #ff6700;
  }
  .price {
    font-size: 14px;
    color: #b0b0b0;
    text-decoration: line-through;
    margin-left: 6px;
  }
  .close {
    position: absolute;
    z-index: -1;
    right: 10px;
    top: 10px;
    &:hover {
      color: #ff6700;
    }
  }
}
</style>